#include <iostream>
#include <algorithm>

using namespace std;

const int N = 100010;

int a[N], b[N], c[N];
int n;

// 返回a中最后一个比b小的元素下标
int find1(int b) {

    if (a[n - 1] < b) {
        return n - 1;
    }

    int l = 0, r = n - 1;
    while (l < r) {
        int mid = l + r >> 1;
        if (a[mid] >= b) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    return l - 1;
}

// 返回c中第一个比b大的元素下标
int find2(int b) {
    if (c[n - 1] <= b) {
        return n;
    }
    int l = 0, r = n - 1;
    while (l < r) {
        int mid = l + r >> 1;
        if (c[mid] > b) {
            r = mid;
        } else {
            l = mid + 1;
        }
    }
    return r;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cin >> n;

    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d", &b[i]);
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d", &c[i]);
    }

    sort(a, a + n);
    sort(c, c + n);

    long long res = 0;
    for (int i = 0; i < n; ++i) {
        int x = find1(b[i]);
        int y = find2(b[i]);
        res += (long long) (x + 1) * (n - y);
    }
    cout << res;
    return 0;
}
